<?php

class Library
{
    public function load_library(){
        $files = new Files();
        $fs = new Functions();
        
        
        
        return array("fs"   =>  $fs,
                     "files"=>  $files);
    }
    
    public function set_javascript_files(){
        $set = $this->load_library();
        $module = $set['fs']->url_module("0");
        $module_1 = $set['fs']->url_module("1");
        
        if(in_array($module_1,unserialize(MODULES))){
            //<script type='text/javascript' src='/js/functions/create_brochure/create_brochure.js'></script>
            $path = 'js/functions/' . $module;
            $files = $set['files']->getAllfiles_fromDirectory($path);
            $ret = "";
            
            foreach($files as $file){
                $ret .= "<script type='text/javascript' src='/" . $path . "/" . $file . "'></script>";
                $ret .= "\n";
            }
            return $ret;
        }
    }
    
    public function get_info(){
        $db = new Database();
        $auth = Auth::getAuth("current_user");
        $info = new Accounts($db,$auth['account_id']);
        
        
        return array("auth" =>  $auth,
                     "info" =>  $info);
    }
    
    public function page_access($name,$style,$class,$id,$attr,$value){
        
        $modules = unserialize(MODULES);
        $ret = "";
        $ret .= '<select name="' . $name . '" ' . $style . ' ' . $attr . ' class="' . $class . '" id="' . $id . '" >';
        $ret .= '<option value="">Select Option</option>';
        if(!empty($value)){
            foreach($modules as $module){
                $mod = str_replace("-", " " ,$module);
                if($value == $module){
                    $selected = "selected=selected";
                }else{
                    $selected = "";
                }
                $ret .= '<option value="' . $module . '" ' . $selected . '  >' . ucwords($mod) . '</option>';
            }
        }
        $ret .= '</select>';
        
        return $ret;
    }
}


?>